package keye.document_manage.dao.sqlserver;

import java.util.HashMap;
import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import keye.document_manage.domain.IsFiles;
import keye.document_manage.entity.Page;
import keye.document_manage.entity.SelectParameters;
import keye.document_manage.util.MySqlProvider;

public interface IsFilesDao {
	int deleteByPrimaryKey(String fileId);

	int insert(IsFiles record);

	int insertSelective(IsFiles record);

	IsFiles selectByPrimaryKey(String fileId);

	int updateByPrimaryKeySelective(IsFiles record);

	int updateByPrimaryKey(IsFiles record);

	/**
	 * 根据表名和 recid确定要发布信息所对应的原文
	 * @param tableName
	 * @param recids 
	 * @return
	 */
	@SelectProvider(type=MySqlProvider.class, method = "getAllByTableAndRecId")
	List<HashMap<String, Object>> getAllByTableAndRecId(@Param("tableName") String tableName, @Param("recids") List<String> recids);

	/**
	 * 根据表名和 recid确定要发布信息所对应的原文
	 * @param tableName
	 * @param recids 形如'id1','id2',id3','id4'的格式
	 * @return
	 */
	@SelectProvider(type=MySqlProvider.class, method = "getFilesByRecid")
	List<HashMap<String, Object>> getFilesByRecid(@Param("where")List<SelectParameters> selectParas, @Param("tableNames") String... tableNames);
	
	@SelectProvider(type=MySqlProvider.class, method = "getFilesByRecid")
	List<HashMap<String, Object>> getFilesByRecidByPage(@Param("page")Page page,@Param("where")List<SelectParameters> selectParas, @Param("tableNames") String... tableNames);

	@SelectProvider(type=MySqlProvider.class, method = "getAllByTableRecId")
	List<HashMap<String, Object>> getAllByTableRecId(@Param("tableName") String tableName, @Param("recids")String recids);

	@Select("select * from is_files where rec_id=#{recId}")
	List<HashMap<String, Object>> getAllByRecId(@Param("recId") String recId);

	@Select("select * from is_files ")
	List<HashMap<String, Object>> getAll();

	/**
	 * 根据表名和 recid得到原文的总大小
	 * @param tableName
	 * @param recids 形如'id1','id2',id3','id4'的格式
	 * @return
	 * @author cdg 2016-2-18 16:29:02
	 */
	@SelectProvider(type=MySqlProvider.class, method = "getFilesTotalLen")
	double getFilesTotalLen(@Param("tableName") String tableName, @Param("recids")String recids);

	/**
	 * 得到所筛选条件的原文总大小
	 * @param selectParas 筛选条件
	 * @param tableNames 表名，多个表名则为多层结构（第一位须为末端层）
	 * @return 原文大小，单位KB
	 * @author cdg 2016年3月1日15:34:21
	 */
	@SelectProvider(type=MySqlProvider.class, method = "getFilesTotalSize")
	Double getFilesTotalSize(@Param("where")List<SelectParameters> selectParas, @Param("tableNames") String... tableNames);

	/**
	 * 根据表名和 recid得到原文的路径字段
	 * @param tableName
	 * @param recids  形如'id1','id2',id3','id4'的格式
	 * @return
	 * @author cdg 2016-2-29 09:19:54
	 */
	@SelectProvider(type=MySqlProvider.class, method = "getFilePathFiled")
	List<HashMap<String, Object>> getFilePathFiled(@Param("tableName") String tableName, @Param("recids")String recids);

	/**
	 * 返回校验错误所需信息
	 * @param selectParas 筛选条件
	 * @param tableNames 表名，多个表名则为多层结构（第一位须为末端层）
	 * @return 档号，题目，表名，原文路径
	 * @author cdg 2016年3月1日16:20:49
	 */
	@SelectProvider(type=MySqlProvider.class, method = "getFilePathInfo")
	List<HashMap<String, Object>> getFilePathInfo(@Param("where")List<SelectParameters> selectParas, @Param("tableNames") String... tableNames);
	
	@SelectProvider(type=MySqlProvider.class, method = "getFilePathInfo")
	List<HashMap<String, Object>> getFilePathInfoByPage(@Param("where")List<SelectParameters> selectParas,@Param("page")Page page, @Param("tableNames") String... tableNames);

}